from sqlalchemy import Column, INTEGER, VARCHAR
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_dm import VARCHAR2, DATE, NUMBER

# 创建对象的基类
Base = declarative_base()

# 生成结果历史类
class dwzd(Base):
    # 模式名
    __table_args__ = {'schema': 'ESUNTEST'}
    # 表名
    __tablename__ = 'HX_BI_DW_ZD'

    ID = Column(VARCHAR(200), primary_key=True)
    XH = Column(VARCHAR(200))
    QYQC = Column(VARCHAR(200))
    QYMC = Column(VARCHAR(200))
    QYDM = Column(VARCHAR(200))
    HYFL = Column(VARCHAR(200))
    HYFLMC = Column(VARCHAR(200))
    ZYFL = Column(VARCHAR(200))
    CBPJ = Column(VARCHAR(200))
    DWLB = Column(VARCHAR(200))
    C1 = Column(VARCHAR(200))
    C2 = Column(VARCHAR(200))
    C3 = Column(VARCHAR(200))
    MYLX = Column(VARCHAR(200))
    YEAR = Column(VARCHAR(200))
    PCH = Column(VARCHAR(200))
    DWXZ = Column(VARCHAR(200))
    GS = Column(VARCHAR(200))
    IMPORT = Column(VARCHAR(200))
    IS_CURRENT = Column(VARCHAR(200))

    @classmethod
    def from_dict(cls, data):
        return cls(
            ID=data['id'],
            XH=data['XH'],
            QYQC=data['QYQC'],
            QYMC=data['QYMC'],
            QYDM=data['QYDM'],
            HYFL=data['HYFL'],
            HYFLMC=data['HYFLMC'],
            ZYFL=data['ZYFL'],
            CBPJ=data['CBPJ'],
            DWLB=data['DWLB'],
            C1=data['C1'],
            C2=data['C2'],
            C3=data['C3'],
            MYLX=data['MYLX'],
            YEAR=data['YEAR'],
            PCH=data['PCH'],
            DWXZ=data['DWXZ'],
            GS=data['GS'],
            IMPORT=data['IMPORT'],
            IS_CURRENT=data['IS_CURRENT'],
        )

    def to_dict(self):
        return {
            'ID': self.ID,
            'XH': self.XH,
            'QYQC': self.QYQC,
            'QYMC': self.QYMC,
            'QYDM': self.QYDM,
            'HYFL': self.HYFL,
            'HYFLMC': self.HYFLMC,
            'ZYFL': self.ZYFL,
            'CBPJ': self.CBPJ,
            'DWLB': self.DWLB,
            'C1': self.C1,
            'C2': self.C2,
            'C3': self.C3,
            'MYLX': self.MYLX,
            'YEAR': self.YEAR,
            'PCH': self.PCH,
            'DWXZ': self.DWXZ,
            'GS': self.GS,
            'IMPORT': self.IMPORT,
            'IS_CURRENT': self.IS_CURRENT,
        }